package com.we823.cms.repository.service.extension;

import java.util.List;

import com.github.pagehelper.PageInfo;
import com.we823.cms.common.web.pageable.PageRequest;
import com.we823.cms.common.web.pageable.Sort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.we823.cms.model.extension.ProductCategory;
import com.we823.cms.repository.dao.extension.ProductCategoryMapper;
import com.we823.cms.repository.service.AbstractBaseService;

@Service("productCategoryService")
@Scope("prototype")
public class ProductCategoryService extends AbstractBaseService<ProductCategory, Integer> {

	private ProductCategoryMapper productCategoryMapper;
	@Autowired
	public ProductCategoryService(ProductCategoryMapper productCategoryMapper) {
		super(productCategoryMapper);
		this.productCategoryMapper = productCategoryMapper;
	}
	public List<ProductCategory> findByParentid(Integer parentid, Sort sort) {
		setSortInfo(sort);
		return this.findByParentid(parentid);
	}

	public PageInfo<ProductCategory> findByParentid(Integer parentid, PageRequest pageRequest) {
		setPageInfo(pageRequest);
		return new PageInfo<>(this.findByParentid(parentid));
	}
	public List<ProductCategory> findByParentid(Integer categoryId) {
		ProductCategory productCategory = new ProductCategory();
		productCategory.setParentId(categoryId);
		return productCategoryMapper.select(productCategory);
	}
}
